#ifndef OMG_TDDS_DOMAIN_DOMAIN_PARTICIPANT_FACTORY_HPP_
#define OMG_TDDS_DOMAIN_DOMAIN_PARTICIPANT_FACTORY_HPP_

/* Copyright (c) 2009-2010, Real-Time Innovations, Inc.
 * Copyright (c) 2010, Object Management Group, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the names of the above copyright holders nor the names of their
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL A COPYRIGHT HOLDER OR CONTRIBUTOR BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


namespace dds {
    namespace domain {
        DomainParticipantFactory TheParticipantFactory();
    }
}


template <typename DELEGATE>
class tdds::domain::DomainParticipantFactory :
    public dds::core::Reference<DELEGATE>
{
    OMG_DDS_REFERENCE_TYPE(DomainParticipantFactory)

public:
    static DomainParticipantFactory get_instance();

public:
    /**
     * Create a new <code>DomainParticipant</code> object. 
     * The <code>DomainParticipant</code> signifies that the calling 
     * application intends to join the Domain identified by the domain_id 
     * argument.
     * The <code>DomainParticipant</code> will be created with 
     * <code>DomainParticipantQos</code> passed as argument.
     *
     * @param id the id of the domain joined by the new
     *           <code>DomainParticipant</code>.
     * @param qos the QoS settings for the new <code>DomainParticipant</code>
     */
    dds::domain::DomainParticipant create_participant(
        dds::domain::DomainId                           domain_id = 0);
    dds::domain::DomainParticipant create_participant(
        dds::domain::DomainId                           domain_id,
        const dds::domain::DomainParticipantQos&        qos,
        const dds::domain::DomainParticipantListener*   a_listener = NULL,
        const dds::core::status::StatusMask&            mask = dds::core::status::StatusMask::all());
    dds::domain::DomainParticipant create_participant(
        dds::domain::DomainId                           domain_id,
        const std::string&                              qos_library_name,
        const std::string&                              qos_profile_name,
        const dds::domain::DomainParticipantListener*   a_listener = NULL,
        const dds::core::status::StatusMask&            mask = dds::core::status::StatusMask::all());

    /**
     * This operation retrieves a previously created <code>DomainParticipant</code>
     * belonging to specified domain_id. If no such DomainParticipant
     * exists, the operation will return a <it>nil</it> value.
     *
     * @param id the domain id
     */
    dds::domain::DomainParticipant lookup_participant(
        dds::domain::DomainId domain_id);

    const dds::domain::DomainParticipantQos
    default_participant_qos() const;

    void
    default_participant_qos(const dds::domain::DomainParticipantQos& qos);

    void default_participant_qos(const std::string& qos_library_name,
                                 const std::string& qos_profile_name);

    const dds::domain::DomainParticipantFactoryQos qos() const;

    void qos(const dds::domain::DomainParticipantFactoryQos& qos);
};


#endif // !defined(OMG_TDDS_DOMAIN_DOMAIN_PARTICIPANT_FACTORY_HPP_)
